package com.baibei.model;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.google.gson.annotations.SerializedName;

public class AddressInfo implements Parcelable {
    @SerializedName("postCode")
    private String zipCode;
    private int isDefault;
    @SerializedName("receivingAddress")
    private String address;
    @SerializedName("receivingName")
    private String receiver;
    @SerializedName("receivingMobile")
    private String mobile;
    private String id;

    private String region;


    public String getRegion() {
        return region;
    }

    public void setRegion(String region) {
        this.region = region;
    }

    public String getZipCode() {
        return null;
    }

    public void setZipCode(String zipCode) {
        this.zipCode = zipCode;
    }

    public boolean isDefault() {
        return isDefault == 1;
    }

    public void setDefault(int aDefault) {
        isDefault = aDefault;
    }

    public void setDefault(boolean aDefault) {
        isDefault = aDefault ? 1 : 0;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getReceiver() {
        return receiver;
    }

    public void setReceiver(String receiver) {
        this.receiver = receiver;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public AddressInfo() {
    }


    public String getFullAddress() {
        if (TextUtils.isEmpty(region)) return address;
        return region + " " + address;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.zipCode);
        dest.writeInt(this.isDefault);
        dest.writeString(this.address);
        dest.writeString(this.receiver);
        dest.writeString(this.mobile);
        dest.writeString(this.id);
        dest.writeString(this.region);
    }

    protected AddressInfo(Parcel in) {
        this.zipCode = in.readString();
        this.isDefault = in.readInt();
        this.address = in.readString();
        this.receiver = in.readString();
        this.mobile = in.readString();
        this.id = in.readString();
        this.region = in.readString();
    }

    public static final Creator<AddressInfo> CREATOR = new Creator<AddressInfo>() {
        @Override
        public AddressInfo createFromParcel(Parcel source) {
            return new AddressInfo(source);
        }

        @Override
        public AddressInfo[] newArray(int size) {
            return new AddressInfo[size];
        }
    };
}
